-- 33.lua
-- Created by zouyb Jun/26/2015
-- 食人魔BUFF光效

return {
    onAppear = function(monster)   

	end,

    onDamaged = function(monster)    
	    -- 当前怪物的基类ID
		local baseClassId = monster:query("base_class_id");

        local monsterGrid = UIDungeonMgr:getCurLevel().grids[monster:getPos()];

		-- 当前血量
		local curHp = monster:getHp();
		local maxHp = monster:getMaxHp();
			
        if curHp > 0 and curHp < maxHp and not monster.hasPlayedBuff then     
			-- 自身播放“怪物出现”效果
			playMonsterFirstAppearEffect(monsterGrid);

			-- 场上全体怪物，播放“属性增益”光效
			local openMonsterGrids = UIDungeonMgr:getCurLevel():getOpenMonsterGrids();
            for i = 1, #openMonsterGrids do
    			local tempGrid = openMonsterGrids[i];
    			if tempGrid ~= monsterGrid then
    				playAddBuffEffect(tempGrid, BUFF_TYPE_ATTACK);
    			end
    		end

			monster.hasPlayedBuff = true;
		end
    end,
};